package cn.edu.nuc.creditSystem.bean;

import java.lang.reflect.Field;
import java.util.Arrays;

public abstract  class BaseBean {
	/**
	 * ID
	 */
	private Integer id;
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	public String toString(){
		Field[] fields=this.getClass().getSuperclass().getDeclaredFields();
		Field[] fieldsthis=this.getClass().getDeclaredFields();
		int fieldslen=fields.length,fieldsthislen=fieldsthis.length;
		fields=Arrays.copyOf(fields,fieldslen+fieldsthislen);
		System.arraycopy(fieldsthis, 0, fields,fieldslen,fieldsthislen);
		StringBuilder sb=new StringBuilder();
		sb.append(this.getClass().getName()+"[");
		for(Field field:fields){
			field.setAccessible(true);
			try {
					sb.append(field.getName()+"="+field.get(this)+",");
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		sb=new StringBuilder(sb.substring(0,sb.length()-1));
		sb.append("]");
		return sb.toString();
	}
}
